package cn.cstech.aijia.model;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created with Android Studio.
 * Title:DesignerInfo
 * Description:
 * Copyright:Copyright (c) 2014
 * Company:中国平安健康保险有限公司
 * Author:Alice
 * Date:15/9/2
 * Time:下午1:45
 * Version 1.0
 */
public class DesignerInfo extends BaseDataHeader implements Serializable {
    private static final long serialVersionUID = 3649294993807017939L;

    public String id;
    //用户名
    public String name;
    //就职公司
    public String company;
    //设计方案数
    public String designNum;
    //好评数
    public String fav;
    //多少一平米
    public String price;
    //头像
    public String icon;
    //距离
    public String distance;

    public static DesignerInfo deserialize(String json) throws JSONException {
        if (json != null && !json.isEmpty()) {
            return deserialize(new JSONObject(json));
        }
        return null;
    }

    public static DesignerInfo deserialize(JSONObject json) throws JSONException {
        if (json != null && json != JSONObject.NULL && json.length() > 0) {
            DesignerInfo result = new DesignerInfo();

            if (!json.isNull("id")) {
                result.id = json.optString("id", null);
            }

            if (!json.isNull("name")) {
                result.name = json.optString("name", null);
            }

            if (!json.isNull("company")) {
                result.company = json.optString("company", null);
            }

            if (!json.isNull("designNum")) {
                result.designNum = json.optString("designNum", null);
            }

            if (!json.isNull("fav")) {
                result.fav = json.optString("fav", null);
            }

            if (!json.isNull("price")) {
                result.price = json.optString("price", null);
            }

            if (!json.isNull("icon")) {
                result.icon = json.optString("icon", null);
            }

            if (!json.isNull("distance")) {
                result.distance = json.optString("distance", null);
            }
            return result;
        }
        return null;
    }
}
